package com.homework.week2;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class OkHttpClintDemo {

    private static OkHttpClient client = new OkHttpClient();
    private static String url = "http://localhost:8801";

    public static void main(String[] args) throws IOException {
        requestURL(url,client);
    }

    public static void requestURL(String url, OkHttpClient client) throws IOException {
        Request request = new Request.Builder().get().url(url).build();
        Response response =client.newCall(request).execute();
        String data = response.body().string();
        System.out.print("response:");
        System.out.println(data);
    }

}
